package com.bsoft.exchange.config.cxf;

import javax.xml.ws.Endpoint;

import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.bsoft.exchange.webservice.RegisterWebService;
import com.bsoft.exchange.webservice.UserService;

@Configuration
public class CxfConfig {

	@Autowired
	private SpringBus bus;

	@Autowired
	UserService userService;
	
	@Autowired
	RegisterWebService registerWebService;
	
	
//	@Autowired
//	YljgService yljgService;

	@Bean(name = "cxfServlet")
	public ServletRegistrationBean dispatcherServlet() {
		return new ServletRegistrationBean(new CXFServlet(), "/exchange-ws/*");
	}

	@Bean
	public Endpoint endpoint() {
		EndpointImpl endpoint = new EndpointImpl(bus, userService);
		endpoint.publish("/user");

		return endpoint;
	}
	
	@Bean
	public Endpoint endpoint2() {
		EndpointImpl endpoint = new EndpointImpl(bus, registerWebService);
		endpoint.publish("/register");

		return endpoint;
	}
	
/*	@Bean
	public Endpoint endpoint2() {
		EndpointImpl endpoint2 = new EndpointImpl(bus, yljgService);
		endpoint2.publish("/yljg");
		return endpoint2;
	}*/

}